package com.xiaomi.front.service.user;

import com.xiaomi.front.dao.User.UserDao;
import com.xiaomi.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    //实现前台登陆,账户密码正确则登陆
    @Override
    public User Login(String number, String pwd) {
        return userDao.Login(number, pwd);
    }

    @Override
    public User DefaultLogin(String number, String pwd) {
        return userDao.DefaultLogin(number, pwd);
    }

    /*
    注册验证
    调用dao层Userexist,查找用户手机号是否存在
    存在返回-1，不存在 则可以注册
     */
    @Override
    public int RegUser(String phone, String password, String username) {
        User user = userDao.Userexist(phone);
        if (user != null) {
            return -1;
        } else {
            return userDao.RegUser(phone, password, username);
        }
    }

    //修改登陆时间
    @Override
    public int LoginTime(int id) {
        return userDao.LoginTime(id);
    }

    //修改密码
    @Override
    public int UpdatePass(String password1, String password, String phone) {
        return userDao.UpdatePass(password1, password, phone);
    }

    @Override
    public int Updateinfo(User user) {
        return userDao.Updateinfo(user);
    }
}
